Name the author and date
Specify the reference number such as SFDC, CSDV or your internal reference number
Describe the purpose of the Groovy code
Specify where the Groovy is executed, with examples being: at a gate, unit updates, or custom DME (data model extensions)
Changes To Existing Code Comments
If updating or making any change (such as making functional changes or upgrading for compatibility) comments should be added so that the various authors can be seen and the reasoning understood:
//dickspa: 01/07/2013: Added in response to CSDV-1147
if (StringUtils.isNotBlank(handlingUnitNbr)){
xmlresponse.append(composeXMLMessageLine("HU_NUMBER", handlingUnitNbr));
}
else {
log("Failed to identify the HU_NUMBER parameter.Not included in outgoing message.");
}
It is considered best practice to write Groovy as if the program was being written in Java. This means following standards such as:
Ending each line with a semi-colon
Using Java syntax for for-loops
Always using the concrete, exact Object type if known; this means using 'Unit' or 'UnitFacilityVisit' instead of 'def'.
Always add a Code Extension to N4 at GLOBAL scope. Adding at any other scope level can lead to issues in a clustered production environment.